#!/usr/bin/env python 
#-*-encoding:utf8-*-


def get_src_data(filename):
    with open(filename,'r') as src:
        _list = []
        for line in src:
            minute_time,city,ci,area_id,flow = line.split('|')
            sub_list = [minute_time.strip(),int(area_id),int(ci),int(city),int(flow)]
            _list.append(sub_list)
        return _list


def get_target_data(filename):
    with open(filename,'r') as src:
        _list = []
        for line in src:
            src_time,target_time,area_id,flow = line.split('|')
            sub_list = [target_time.strip(),int(area_id),int(flow)]
            _list.append(sub_list)
        return _list


def get_area_ci_dict(map_filename):
    with open(map_filename,'r') as src:
        map_area_ci = dict()
        for line in src:
            area_id,ci_id,city_id,add_time=line.split('|')
            map_area_ci.setdefault(area_id,[])
            map_area_ci[area_id].append(city_id+'_'+ci_id)
        
        for k in map_area_ci.keys():
            #print len(map_area_ci[k])
            map_area_ci[k].sort()
        return map_area_ci


